<?php
/**
 * Created by PhpStorm.
 * User: BlueIdeaLirui
 * Date: 2020/03/10
 * Time: 上午10.17
 */

namespace business\base\services;

class StopWordsService
{
    /**
     * 过滤停用词
     * @param $word
     * @return mixed
     */
    public static function filter($word)
    {
        if (!empty($word)) {
            $sql = <<<sql
            SELECT
                word
            FROM
                b2b_search.stop_words_filter
            WHERE
                is_close = 0
                AND is_deleted = 0
sql;
            $filterWords = \Yii::$app->db->createCommand($sql)->queryColumn();

            return !empty($filterWords) ? str_replace($filterWords, '', $word) : $word;
        }

        return $word;
    }
}
